package sh.wnxy.wn38.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import sh.wnxy.wn38.entity.Ticket;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.time.LocalDate;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wn38
 * @since 2021-07-14
 */
@Mapper
public interface TicketMapper extends BaseMapper<Ticket> {
    @Update("update ticket set ticket_stock=ticket_stock+#{num} where ticket_date=#{date} and ticket_version=#{spottype} " +
            "and ticket_spotid=#{id}")
    Integer addnum(@Param("date")LocalDate date, @Param("id")Integer id, @Param("spottype")String spottype,@Param("num") Integer num);
    @Update("update ticket set ticket_stock=ticket_stock-#{number} where ticket_date=#{date} and ticket_version=#{kind} " +
            "and ticket_spotid=#{id}")
    Integer subnum(@Param("date") LocalDate date,@Param("id") Integer id,@Param("kind") String kind,@Param("number") Integer number);
    @Select("Select ticket_id from ticket where ticket_date=#{date} and ticket_version=#{kind} " +
            "and ticket_spotid=#{id}")
    Integer selectBydate(@Param("date")LocalDate date, @Param("id")Integer id, @Param("kind")String spottype);
}
